package com.wntime.simulator.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wntime.simulator.domain.Simulator;
import com.wntime.simulator.mapper.SimulatorMapper;
import com.wntime.simulator.service.SimulatorService;
import org.springframework.stereotype.Service;

@Service
public class SimulatorServiceImpl extends ServiceImpl<SimulatorMapper, Simulator> implements SimulatorService {

    @Override
    public Integer getMaxPort() {
        return baseMapper.selectMaxPort();
    }

    @Override
    public int selectName(String name) {
        String[] split = name.split("_");

        QueryWrapper<Simulator> wrapper = new QueryWrapper<>();
        wrapper.likeRight("name", split[0]);
        return Math.toIntExact(baseMapper.selectCount(wrapper));
    }
}
